<?php

App::import('Core', 'Component');

class BAuthComponent extends Component {
  public $components = array('Session');
  private $controller = NULL;
  public $loginRedirect = array('controller' => 'points', 'action' => 'home');
  public $logoutRedirect = array('controller' => 'points', 'action' => 'home');
  public $enabled = TRUE;

  function initialize(&$controller) {
    $this->controller = $controller;

    /*
    $this->allow('*');
    $this->deny('claim');
    $this->deny('link');
    
    $this->Auth->authenticate = ClassRegistry::init('User');
    
    $this->Auth->fields = array('username' => 'email', 'password' => 'password');

    // check to see if user is signed in with facebook
    $this->__checkFBStatus();

    // send all user info to the view
    $this->set('fb_apikey', $this->__fbApiKey);
    */
  }
  
  // important for controller.redirect()
  function beforeRedirect($controller, $url, $status = NULL, $exit = TRUE) {
  } 
   
  function user() {
    return $this->Session->read('user');
  }

  function login($account) {
    $this->Session->write('user', $account);
    return $account ? $this->loginRedirect : FALSE;
  }

  function logout() {
    $this->Session->write('user', NULL);
    return $this->logoutRedirect;
  }
  
  function password($password) {}
}
